﻿@model TDT.Land.Entity.Cus_Land
@{
    ViewBag.Title = "Land_List";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
@section HeaderContent{
    <script src="../../Scripts/editor/ckeditor.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {

            $("#ProvinceId").change(function () {
                var proId = this.value;
                var dt = new Date();
                var href = "/Home/getDistrict?ProId=" + proId + "&dt=" + dt.getTime();
                $("#div_district").load(href);
            });

            $(function () {
                $("#fuser").ajaxForm({
                    iframe: true,
                    dataType: "json",
                    beforeSubmit: function () {
                        // su kien truoc khi up image
                    },
                    success: function (result) {
                        cusAlert("Save ok");
                        onCancel();
                    },
                    error: function (xhr, textStatus, errorThrown) {
                        cusAlert(" fail");
                    }
                });
            });
        });
        function onsave() {
            $("#fuser").submit();
        }
        function onCancel() {
            window.location.assign("/CusLand/AD_CuslandList");
        }

        function SetAltValue(value) {
            var _value = change_alias(value);
            $("#url").val(_value);
        }

        function change_alias(alias) {
            var str = alias;
            str = str.toLowerCase();
            str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ |ặ|ẳ|ẵ/g, "a");
            str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
            str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
            str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ |ợ|ở|ỡ/g, "o");
            str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
            str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
            str = str.replace(/đ/g, "d");
            str = str.replace(/!|@@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'| |\"|\&|\#|\[|\]|~|$|_/g, "-");
            /* tìm và thay thế các kí tự đặc biệt trong chuỗi sang kí tự - */
            str = str.replace(/-+-/g, "-"); //thay thế 2- thành 1-
            str = str.replace(/^\-+|\-+$/g, "");
            //cắt bỏ ký tự - ở đầu và cuối chuỗi
            return str;
        }


    </script>
}
@section Toolbar {
    <a class="btn_boder btn_save" onclick="onsave()">Save</a> 
    <a onclick="onCancel()" class="close btn_boder btn_cancel">Cancel</a> 
    @*<a class="btn_boder btn_back" onclick="onCancel()">Back List</a>*@
}
<div>
    <form id="fuser" action="/CusLand/LandAction" method="post" enctype="multipart/form-data">
        <table class="tbEdit" cellpadding="0" cellspacing="0">
            <tr>
                <th style="width: 150px"></th>
                <td style="width: 150px"></td>
                <th style="width: 100px"></th>
                <td style="width: 150px"></td>
            </tr>

            <tr>
                <th>@Cus_Land.FieldName.Code.Translate()</th>
                <td>@Html.TextBoxFor(m => m.Code)</td>

                <th>Têu đề</th>
                <td>@Html.TextBoxFor(m=>m.Title, new { onkeyup = "SetAltValue(this.value);" })
                </td>
            </tr>

            <tr>
                <th>Alt</th>
                <td>@*@Html.TextBox("url", Model.url)*@
                    @Html.TextBoxFor(m=>m.url)
                </td>

                <th>@Cus_Land.FieldName.BDSLandName.Translate()</th>
                <td>@Html.DropDownListFor(m => m.LandID, (List<SelectListItem>)ViewBag.select_CatLand, new { style = "width:138px" })
                </td>
            </tr>

            <tr>
                <th>@Cus_Land.FieldName.BDSTypeName.Translate()</th>
                <td>@Html.DropDownListFor(m => m.BDSTypeID, (List<SelectListItem>)ViewBag.select_CatBDSType, new { style = "width:138px" })
                </td>

                <th>@Cus_Land.FieldName.PuposeType.Translate()</th>
                 <td>@Html.DropDownListFor(m => m.PuposeType, (List<SelectListItem>)ViewBag.select_PuposeType, new { style = "width:138px" })
                </td>
                
            </tr>
            <tr>
                <th>@Cus_Land.FieldName.Currency.Translate()</th>
                <td>@Html.DropDownListFor(m => m.BDSTypeID, (List<SelectListItem>)ViewBag.select_Currency, new { style = "width:138px" })
                </td>


                <th>@Cus_Land.FieldName.IsShowMoney.Translate()</th>
                <td>@Html.EditorFor(m => m.IsShowMoney)</td>
            </tr>
            <tr>
                <th>@Cus_Land.FieldName.CostPerMeter.Translate()</th>
                <td>@Html.EditorFor(m => m.CostPerMeter)</td>


                <th>@Cus_Land.FieldName.StreetWidth.Translate()</th>
                <td>@Html.EditorFor(m => m.StreetWidth)</td>
            </tr>
            <tr>
                <th>@Cus_Land.FieldName.NumBedRoom.Translate()</th>
                <td>@Html.EditorFor(m => m.NumBedRoom)</td>


                <th>@Cus_Land.FieldName.NumRestRoom.Translate()</th>
                <td>@Html.EditorFor(m => m.NumRestRoom)</td>
            </tr>
            <tr>
                <th>@Cus_Land.FieldName.NumAddress.Translate()</th>
                <td>@Html.EditorFor(m => m.NumAddress)</td>


                <th>@Cus_Land.FieldName.StreetAddress.Translate()</th>
                <td>@Html.EditorFor(m => m.StreetAddress)</td>
            </tr>

            <tr>
                <th>@Cus_Land.FieldName.NameContact.Translate()</th>
                <td>@Html.EditorFor(m => m.NameContact)</td>


                <th>@Cus_Land.FieldName.CellPhoneContact.Translate()</th>
                <td>@Html.EditorFor(m => m.CellPhoneContact)</td>
            </tr>

            <tr>
                <th>@Cus_Land.FieldName.HomePhoneContact.Translate()</th>
                <td>@Html.EditorFor(m => m.HomePhoneContact)</td>


                <th>@Cus_Land.FieldName.EmailContact.Translate()</th>
                <td>@Html.EditorFor(m => m.EmailContact)</td>
            </tr>

            <tr>
                <th>@Cus_Land.FieldName.TotalCost.Translate()</th>
                <td>@Html.TextBoxFor(m => m.TotalCost)</td>
                <th>@Cus_Land.FieldName.NumAddress.Translate()</th>
                <td>@Html.EditorFor(m => m.NumAddress)</td>
            </tr>
            <tr>
                <th>@Cus_Land.FieldName.Direction.Translate()</th>
                <td>
                    @Html.DropDownListFor(m => m.Direction, (List<SelectListItem>)ViewBag.select_Direction, new { style = "width:138px" })
                </td>
                <th>@Cus_Land.FieldName.Area.Translate()</th>
                <td>
                    @Html.EditorFor(m => m.Area)
                </td>
            </tr>

            <tr>
                <th>@Cus_Land.FieldName.NumFloor.Translate()
                </th>
                <td>
                    @Html.EditorFor(m => m.NumFloor)
                </td>
                <th>@Cus_Land.FieldName.NumRestRoom.Translate()
                </th>
                <td>
                    @Html.EditorFor(m => m.NumRestRoom)
                </td>
            </tr>

            <tr>
                <th>@Cus_Land.FieldName.ProvinceName.Translate()
                </th>
                <td>
                    @Html.DropDownListFor(m => m.ProvinceID, (List<SelectListItem>)ViewBag.select_Province, new { style = "width:138px" })
                </td>
                <th>@Cus_Land.FieldName.DictrictName.Translate()
                </th>
                <td>
                    <div id="div_district">
                        @Html.Partial("US_District_view")
                    </div>
                    @*@Html.DropDownListFor(m => m.DistrictId, (List<SelectListItem>)ViewBag.select_District, new { style = "width:138px" })*@
                </td>

            </tr>
            <tr>
                <th>@Cus_Land.FieldName.WardName.Translate()
                </th>
                <td>
                    <div id="div_Ward">
                        @Html.Partial("US_Ward_view")
                    </div>
                    @*@Html.DropDownListFor(m => m.WardId, (List<SelectListItem>)ViewBag.select_Ward, new { style = "width:138px" })*@
                </td>
                <th>@Cus_Land.FieldName.LegalPaper.Translate()
                </th>
                <td>
                    @Html.DropDownListFor(m => m.LegalPaper, (List<SelectListItem>)ViewBag.select_LegalPaper, new { style = "width:138px" })
                </td>
            </tr>
            <tr>
                <th>@Cus_Land.FieldName.Comment.Translate()
                </th>
            </tr>
            <tr>
                 <td colspan="4">
                    @Html.TextAreaFor(m => m.Comment,new { style = "width:100%" })
                </td>
            </tr>
            <tr>
                <td colspan="4" align="center">
                    @Html.HiddenFor(m => m.ID)
                    @*<input type="button" value="Tạo mới" />*@
                </td>
            </tr>
        </table>
    </form>
</div>

